package com.pactera.madp.cp.service.sync.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pactera.madp.cp.api.entity.sync.SyncSysCodeSetInfoHisEntity;
import com.pactera.madp.cp.mapper.sync.SyncSysCodeSetInfoHisMapper;
import com.pactera.madp.cp.service.sync.SyncSysCodeSetInfoHisService;
import org.springframework.stereotype.Service;

@Service
public class SyncSysCodeSetInfoHisServiceImpl extends ServiceImpl<SyncSysCodeSetInfoHisMapper, SyncSysCodeSetInfoHisEntity> implements SyncSysCodeSetInfoHisService {

    @Override
    public void syncOneDay(String syncDate) {
        // 1.0 删除存在的数据
        this.remove(Wrappers.<SyncSysCodeSetInfoHisEntity>lambdaQuery().
                eq(SyncSysCodeSetInfoHisEntity::getSyncDate, syncDate));
        // 2.0 批量插入要同步的数据
        baseMapper.syncData(syncDate);
    }

    @Override
    public void deleteOneDate(String date) {
        this.remove(Wrappers.<SyncSysCodeSetInfoHisEntity>lambdaQuery().
                le(SyncSysCodeSetInfoHisEntity::getSyncDate, date));
    }

}